<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:include="public/page_css::page_css ('预期到货明细')" />

<body>
<div class="layui-fluid larry-wrapper">
    <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm1">
        <input type="hidden" th:value="${id}" id="pid" name="id">
        <input type="hidden" th:value="${shzt}" id="shztId" name="shzt">
        <input type="hidden" th:value="${gysid}" id="gysId" name="gysid">
    </form>
    <div class="pro">
        <table id="table8"  class="table text-nowrap"></table>
    </div>
</div>
</body>
<div th:include="public/public_js::public_js"></div>

<script th:inline="javascript">
    $(function () {
    })

</script>
<script>
    var tabs;
    layui.use(['myform','zzpUtils','form','jquery'],function () {
        window.operateEvent = {

            "click #btn_edit": function (e, value, row, index) {//编辑
                edit(row);
            }
        }

        var  zzpUtils = layui.zzpUtils,
            $ = layui.jquery;

        tabs = zzpUtils.table({
            elem: '#table8',
            isApi: true,
            pagination:false,
            columns: [{
                field: 'hpbh',
                title: '货品编号'
            }, {
                field: 'hpmc',
                title: '货品名称'
            },{
                field: 'gg',
                title: '规格'
            },{
                field: 'nc',
                title: 'NC编码'
            }, {
                field: 'ms',
                title: '主单位'
            }, {
                field: 'hppc',
                title: '货品批次'
            }, {
                field: 'scrq',
                title: '生产日期'
            }, {
                field: 'yqsl',
                title: '主单位数量'
            }, {
                field: 'xdwsl',
                title: '箱单位数量'
            }, {
                field: 'show_zt',
                title: '状态'
            }, {
                field: 'show_zjzt',
                title: '质检状态'
            }, {
                field: 'sdsl',
                title: '收货数量'
            }, {
                field: 'sxrq',
                title: '失效日期',
                visible:false
            }, {
                field: 'pssl',
                title: '破损数量',
                visible:false
            }, {
                field: 'jssl',
                title: '拒收数量',
                visible:false
            }, {
                field: 'wssl',
                title: '未收数量',
                visible:false
            }, {
                field: 'tj',
                title: '体积',
                visible:false
            }, {
                field: 'jz',
                title: '净重',
                visible:false
            }, {
                field: 'zl',
                title: '毛重',
                visible:false
            }, {
                field: 'caozuo',
                title: '操作',
                events: operateEvent,
                formatter: operateFormatter
            }]

        });

        /*表格右侧按钮*/
        function operateFormatter(value, row, index) {
            //审核状态
            var shzt=$('#shztId').val();
            if (shzt=='0') {
                return [
                    '<a class="layui-btn layui-btn-xs layui-btn-normal" style="text-decoration: none" id="btn_edit">编辑</a>'
                ].join('')
            }
        }
        //编辑
        function  edit(row){
            var url, dialog = zzpUtils.dialogBtn;
            dialog.init({
                title: "修改明细",
                id: "shtz",
                type: 2,
                isForm: true,
                subBtn: 'form1btn',
                area: ['90%', '85%'],
                url: "/yqdh/updateMx?id=" + row.id+"&gysid="+$("#gysId").val(),
                beforSubmit: function (iframe) {
                    dialog.form = $("#form1", iframe.document);
                },
                end: function (data) {
                    zzpUtils.refreshTable("#table8");
                }
            });

        }

        $(function () {
            $.ajax({
                url: "/zxsdwms/wmsEstimatedArrivalOrderDetailed/list",
                type: "POST",
                dataType: "JSON",
                contentType: 'application/json',
                async: false,
                data:JSON.stringify({id:$('#pid').val()}),
                success: function (data) {
                    tabs.bootstrapTable('append', data);
                },
                error: function () { console.log("Error"); }
            });
        })

    });
    //将数据传到父级页面
    function shenhe(){
        var rows = tabs.bootstrapTable('getData');
        var ssyqdid=rows[0].ssyqdid;
        return ssyqdid;
    }

</script>
</html>